package com.hj.dapp.config.orc;

import com.aliyun.ocr_api20210707.Client;
import com.aliyun.teaopenapi.models.Config;
import com.hj.dapp.common.constant.OcrConstant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 胡奥程
 * @version 1.0
 * @date 2024/1/2
 */
@Configuration
public class OcrConfig {
    @Bean
    public  Client client() {
        try {
            Config config = new com.aliyun.teaopenapi.models.Config()
                    // 必填，您的 AccessKey ID
                    .setAccessKeyId(OcrConstant.ACCESS_KEY_ID)
                    // 必填，您的 AccessKey Secret
                    .setAccessKeySecret(OcrConstant.SECRET_ACCESS_KEY);
            // Endpoint 请参考 https://api.aliyun.com/product/ocr-api
            config.endpoint = OcrConstant.ENDPOINT;
            return new Client(config);
        } catch (Exception e) {
           e.printStackTrace();
        }
        return null;
    }
}
